package me.shurufa.widget.pulltorefresh;

import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.util.AttributeSet;

import com.bumptech.glide.util.Util;

import in.srain.cube.views.ptr.PtrFrameLayout;
import in.srain.cube.views.ptr.header.MaterialHeader;
import me.shurufa.R;
import me.shurufa.utils.Utils;

public class SrfPtrFrameLayout extends PtrFrameLayout {

    public SrfPtrFrameLayout(Context context) {
        super(context);
        initViews();
    }

    public SrfPtrFrameLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        initViews();
    }

    public SrfPtrFrameLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initViews();
    }

    private void initViews() {

        // header
        final MaterialHeader header = new MaterialHeader(getContext());
        int[] colors = {getContext().getResources().getColor(R.color.red_new)};
        header.setColorSchemeColors(colors);
        header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
        header.setPadding(0, Utils.dp2px(getContext(), 15), 0, Utils.dp2px(getContext(), 10));
        header.setPtrFrameLayout(this);

        setLoadingMinTime(1000);
        setDurationToCloseHeader(500);
        setHeaderView(header);
        addPtrUIHandler(header);
        setResistance(2.0f);

    }

}